package com.chuyunjian.controller;



import com.chuyunjian.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class IndexController {
    @Resource
    private RedisUtil redisUtil;

    @RequestMapping("/setRedis")
    public String setRedis(String key, String value) {
//        redisService.setStr(key, value,20L);
        redisUtil.set(key, value);
        return "success";
    }

    @RequestMapping("/delStringKey")
    public String reStrRedis(String key){
        redisUtil.del(key);
        return "success";
    }

    @RequestMapping("/getKey")
    public Object getKey(String key){
        Object result = redisUtil.get(key);
        return result == null ? "缓存没有该数据" : result;
    }

}